<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/14
 * Time: 16:15
 */
namespace common\sources\write\classifyreason;

use Yii;
use common\models\craftsman\ClassifyReason;

class ClassifyReasonAccess implements IClassifyReasonAccess
{
    public function addClassifyReason($data)
    {
        $res = Yii::$app->db->createCommand()->insert('classify_reason', [
            'audit_type' => $data['audit_type'],
            'class_name' => $data['class_name'],
            'classify_id' =>$data['classify_id'],
            'reason' => $data['reason'],
            'create_time' => time()
        ])->execute();
        return $res;
    }

    public function modifyClassifyReason($data)
    {
        $sql = 'UPDATE ' . ClassifyReason::tableName() . ' SET class_name = :class_name,classify_id = :classify_id,reason = :reason,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':class_name' => $data['class_name'],
                ':classify_id' => $data['classify_id'],
                ':reason' => $data['reason'],
                ':update_time' => time(),
                ':id' => $data['c_id']
            ])->execute();
    }
    public function delClassifyReason($data)
    {
        return Yii::$app->db->createCommand()->delete(ClassifyReason::tableName(), 'id = '.$data['c_id'])->execute();
    }

}